var common = require('../common');
var store = common.store;
var getFile = common.getFile;
module.exports = {
  // 跟据gamecodes获得游戏信息
  "get /admin/third/game/listByGameCode.do": function(req, res) {
    var data = [];
    var i = 0;
    for (;i < 20;i++) {
      data.push({
        name: '游戏名' + i,
        kind: '游戏类型',
        platform: '平台类型'
      });
    }
    res.send({
      "result": "success",
      "messages": [],
      "fieldErrors": {},
      "errors": [],
      "data": data
    });
  },
  "post /gamelib/listByGamecodes.do": function(req, res) {
    res.send({
      "result": "success",
      "messages": [],
      "fieldErrors": {},
      "errors": [],
      "data": [{
        "gameCode": "111", //游戏代码，由：platform（4位)+kind(2位)+id(8位)组成
        "gameBase": //游戏基础信息
        {
          "id": "12321", //游戏id
          "name": "刀塔", //游戏中文名
          "enName": "string", //游戏英文名
          "firstChar": "string", //首字母
          "pinYin": "string", //拼音
          "status": "12321", //状态，0为已删除，1为可用，2为未完善
          "creator": "string", //创建人
          "createTime": "12321", //创建时间，UNIX时间戳，单位秒
          "updateTime": "12321" //更新时间，UNIX时间戳，单位秒
        },
        "gameId": "12321", //游戏id
        "oldGameCode": "12321", //原平台游戏代码
        "platform": "PC", //平台类型，如：PC/NDS/3DS/PS3
        "kind": "单机" //业务类型，如：网络/单机
      }]
    });
  },
  // 游戏库搜索
  "get /admin/third/game/search.do": function(req, res) {

    var pageNo = req.param('pageNo');
    var pageSize = req.param('pageSize');
    var totalCount = 50;
    var listData = [];
    console.log('pageNo:' + pageNo)
    for (var i = 0; i < totalCount; i++) {
      listData.push({
        gameCode: 20140700 + i,
        name: '游戏名称' + i,
        "platform": "PC", //平台类型，如：PC/NDS/3DS/PS3
        "kind": "单机" //业务类型，如：网络/单机
      });
    }
    var pageData = common.getPageData(listData, pageNo, pageSize);
    console.log(pageData)
    res.send({
      result: 'success',
      messages: [],
      fieldErrors: {},
      errors: [],
      data: {
        totalCount: totalCount,
        pageSize: pageData.pageSize,
        pageNo: pageData.pageNo,
        listData: pageData.listData
      }
    });

  },
  // mock freeMarker 文件
  "get /url": function(req, res) {
    this.render.ftl(getFile('path'), store);
  }

};
